package com.gscitysfy.cus.drain.modules.command.convert;

import com.gscitysfy.cloudfrmwk.assistant.domain.Result;
import com.gscitysfy.cloudfrmwk.portal.feign.DistrictService;
import com.gscitysfy.cus.drain.modules.command.dto.DrainDangerMsgPublishDto;
import com.gscitysfy.cus.drain.modules.command.entity.DangerSituationManage;
import com.gscitysfy.cus.drain.modules.command.entity.DrainDangerMsgPublish;
import com.gscitysfy.cus.drain.modules.common.entity.DrainInspectionMnFile;
import com.gscitysfy.cus.drain.modules.common.mapper.DrainInspectionMnFileMapper;
import lombok.AllArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * @Author jiang_wen
 * @Date 2022/10/20 21:11
 * @Description TODO
 */
@AllArgsConstructor
@Component
public class DrainDangerMsgPublishConvert {

    private final DrainInspectionMnFileMapper fileMapper;
    private final DistrictService districtService;

    public DrainDangerMsgPublish toEntity(DrainDangerMsgPublish drainDangerMsgPublish, DrainDangerMsgPublishDto drainDangerMsgPublishDto) {
        SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        drainDangerMsgPublish.setContentTemplatesId(drainDangerMsgPublishDto.getContentTemplatesId());
        drainDangerMsgPublish.setDangerId(drainDangerMsgPublishDto.getDangerId());
        drainDangerMsgPublish.setMsgTransRegion(drainDangerMsgPublishDto.getMsgTransRegion());
        drainDangerMsgPublish.setTransType(drainDangerMsgPublishDto.getTransType());
        drainDangerMsgPublish.setPublishContent(drainDangerMsgPublishDto.getPublishContent());
        drainDangerMsgPublish.setNetTransType(drainDangerMsgPublishDto.getNetTransType());

        drainDangerMsgPublish.setMsgTransRegionName(drainDangerMsgPublishDto.getMsgTransRegionName());
        drainDangerMsgPublish.setNetTransTypeName(drainDangerMsgPublishDto.getNetTransTypeName());
        try {
            if (StringUtils.isNotEmpty(drainDangerMsgPublishDto.getTransTime())) {
                drainDangerMsgPublish.setTransTime(sdf1.parse(drainDangerMsgPublishDto.getTransTime()));
            }else{
                drainDangerMsgPublish.setTransTime(new Date());

            }
        }catch (Exception e){
            drainDangerMsgPublish.setTransTime(new Date());
        }
    return drainDangerMsgPublish;
    }


}
